import http from '../../common/http'
Page({
  data: {
    // 定义轮播图图片资源
    img: [
      '../../imgs/b1.jpg',
      '../../imgs/b2.jpg',
      '../../imgs/b3.jpg',
      '../../imgs/b4.jpg'
    ],
    pagenum: 1,
    isShow: false,
    isLoding: false,
    oid: ''
  },
  onLoad(options) {
    this.setData({
      oid: options.id
    })
    http({
      url: 'http://route.showapi.com/1700-2',
      method: 'GET',
      data: {
        showapi_appid: '1367085',
        showapi_sign: 'cb8507c33e4a43cfa34a954c91b91fd6',
        classifyId: options.id,
        page: this.data.pagenum
      },
    }).then(res => {
      // console.log(res);
      // console.log(res.data.showapi_res_body.contentlist);
      // console.log();
      this.setData({
        b: res.data.showapi_res_body.contentlist,
        isShow: true
      })
    })
  },
  xq(e) {
    console.log(e.currentTarget.dataset.id);
    wx.navigateTo({
      url: `../d/d?id=${e.currentTarget.dataset.id}&title=${e.currentTarget.dataset.title}`,
    })
  },
  onReachBottom() {
    this.setData({
      isLoding: true,
      pagenum: ++this.data.pagenum
    })
    http({
      url: 'http://route.showapi.com/1700-2',
      method: 'GET',
      data: {
        showapi_appid: '1367085',
        showapi_sign: 'cb8507c33e4a43cfa34a954c91b91fd6',
        classifyId: this.data.oid,
        page: this.data.pagenum
      },
    }).then(res => {
      // console.log(res);
      console.log(res.data.showapi_res_body);
      // console.log();
      this.setData({
        b: this.data.b.concat(res.data.showapi_res_body.contentlist),
        isLoding: false
      })
    })
    console.log('上拉触底');
  },

})